// $ANTLR 3.1.3 Mar 17, 2009 19:23:44 G3D.g 2009-08-27 17:15:29


using System;
using Antlr.Runtime;
using IList 		= System.Collections.IList;
using ArrayList 	= System.Collections.ArrayList;
using Stack 		= Antlr.Runtime.Collections.StackList;


namespace 
	GeometryViz3D.Model

{
public class G3DParser : Parser 
{
    public static readonly string[] tokenNames = new string[] 
	{
        "<invalid>", 
		"<EOR>", 
		"<DOWN>", 
		"<UP>", 
		"POINT", 
		"ID", 
		"LINE", 
		"CharacterLiteral", 
		"StringLiteral", 
		"HexLiteral", 
		"OctalLiteral", 
		"DecimalLiteral", 
		"FloatingPointLiteral", 
		"P", 
		"O", 
		"I", 
		"N", 
		"T", 
		"L", 
		"E", 
		"V", 
		"C", 
		"R", 
		"VECTOR", 
		"A", 
		"B", 
		"D", 
		"F", 
		"G", 
		"H", 
		"J", 
		"K", 
		"M", 
		"Q", 
		"S", 
		"U", 
		"W", 
		"X", 
		"Y", 
		"Z", 
		"HexDigit", 
		"IntegerTypeSuffix", 
		"FloatTypeSuffix", 
		"EscapeSequence", 
		"UnicodeEscape", 
		"OctalEscape", 
		"Letter", 
		"Digit", 
		"WS", 
		"COMMENT", 
		"LINE_COMMENT", 
		"'='", 
		"'+'", 
		"'-'"
    };

    public const int O = 14;
    public const int OctalLiteral = 10;
    public const int Digit = 47;
    public const int HexDigit = 40;
    public const int P = 13;
    public const int T__51 = 51;
    public const int V = 20;
    public const int I = 15;
    public const int F = 27;
    public const int U = 35;
    public const int VECTOR = 23;
    public const int S = 34;
    public const int D = 26;
    public const int Letter = 46;
    public const int T__52 = 52;
    public const int R = 22;
    public const int K = 31;
    public const int EscapeSequence = 43;
    public const int B = 25;
    public const int Q = 33;
    public const int M = 32;
    public const int LINE = 6;
    public const int T = 17;
    public const int FloatingPointLiteral = 12;
    public const int FloatTypeSuffix = 42;
    public const int ID = 5;
    public const int IntegerTypeSuffix = 41;
    public const int W = 36;
    public const int H = 29;
    public const int POINT = 4;
    public const int WS = 48;
    public const int CharacterLiteral = 7;
    public const int G = 28;
    public const int COMMENT = 49;
    public const int StringLiteral = 8;
    public const int A = 24;
    public const int LINE_COMMENT = 50;
    public const int N = 16;
    public const int X = 37;
    public const int Z = 39;
    public const int UnicodeEscape = 44;
    public const int HexLiteral = 9;
    public const int C = 21;
    public const int EOF = -1;
    public const int DecimalLiteral = 11;
    public const int T__53 = 53;
    public const int L = 18;
    public const int OctalEscape = 45;
    public const int J = 30;
    public const int Y = 38;
    public const int E = 19;

    // delegates
    // delegators



        public G3DParser(ITokenStream input)
    		: this(input, new RecognizerSharedState()) {
        }

        public G3DParser(ITokenStream input, RecognizerSharedState state)
    		: base(input, state) {
            InitializeCyclicDFAs();

             
       }
        

    override public string[] TokenNames {
		get { return G3DParser.tokenNames; }
    }

    override public string GrammarFileName {
		get { return "G3D.g"; }
    }


    	GeometryViz3D.Model.IModelBuilder m_modelBuilder = null;
    	
    	internal GeometryViz3D.Model.IModelBuilder ModelBuilder
    	{
    		set
    		{
    			m_modelBuilder = value;
    		}
    	}



    // $ANTLR start "model"
    // G3D.g:32:1: model : ( point | line )* ;
    public void model() // throws RecognitionException [1]
    {   
        try 
    	{
            // G3D.g:33:2: ( ( point | line )* )
            // G3D.g:33:4: ( point | line )*
            {
            	// G3D.g:33:4: ( point | line )*
            	do 
            	{
            	    int alt1 = 3;
            	    int LA1_0 = input.LA(1);

            	    if ( (LA1_0 == POINT) )
            	    {
            	        alt1 = 1;
            	    }
            	    else if ( (LA1_0 == LINE) )
            	    {
            	        alt1 = 2;
            	    }


            	    switch (alt1) 
            		{
            			case 1 :
            			    // G3D.g:34:4: point
            			    {
            			    	PushFollow(FOLLOW_point_in_model61);
            			    	point();
            			    	state.followingStackPointer--;


            			    }
            			    break;
            			case 2 :
            			    // G3D.g:35:5: line
            			    {
            			    	PushFollow(FOLLOW_line_in_model67);
            			    	line();
            			    	state.followingStackPointer--;


            			    }
            			    break;

            			default:
            			    goto loop1;
            	    }
            	} while (true);

            	loop1:
            		;	// Stops C# compiler whining that label 'loop1' has no statements


            }

        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return ;
    }
    // $ANTLR end "model"


    // $ANTLR start "point"
    // G3D.g:39:1: point : POINT id= ID '=' x= integerLiteral y= integerLiteral z= integerLiteral (n= stringLiteral )? ;
    public void point() // throws RecognitionException [1]
    {   
        IToken id = null;
        G3DParser.integerLiteral_return x = null;

        G3DParser.integerLiteral_return y = null;

        G3DParser.integerLiteral_return z = null;

        G3DParser.stringLiteral_return n = null;


        try 
    	{
            // G3D.g:40:2: ( POINT id= ID '=' x= integerLiteral y= integerLiteral z= integerLiteral (n= stringLiteral )? )
            // G3D.g:40:4: POINT id= ID '=' x= integerLiteral y= integerLiteral z= integerLiteral (n= stringLiteral )?
            {
            	Match(input,POINT,FOLLOW_POINT_in_point83); 
            	id=(IToken)Match(input,ID,FOLLOW_ID_in_point87); 
            	Match(input,51,FOLLOW_51_in_point89); 
            	PushFollow(FOLLOW_integerLiteral_in_point96);
            	x = integerLiteral();
            	state.followingStackPointer--;

            	PushFollow(FOLLOW_integerLiteral_in_point100);
            	y = integerLiteral();
            	state.followingStackPointer--;

            	PushFollow(FOLLOW_integerLiteral_in_point104);
            	z = integerLiteral();
            	state.followingStackPointer--;

            	// G3D.g:42:4: (n= stringLiteral )?
            	int alt2 = 2;
            	int LA2_0 = input.LA(1);

            	if ( ((LA2_0 >= CharacterLiteral && LA2_0 <= StringLiteral)) )
            	{
            	    alt2 = 1;
            	}
            	switch (alt2) 
            	{
            	    case 1 :
            	        // G3D.g:42:4: n= stringLiteral
            	        {
            	        	PushFollow(FOLLOW_stringLiteral_in_point111);
            	        	n = stringLiteral();
            	        	state.followingStackPointer--;


            	        }
            	        break;

            	}


            				m_modelBuilder.AddPoint(((id != null) ? id.Text : null), ((x != null) ? input.ToString((IToken)(x.Start),(IToken)(x.Stop)) : null), ((y != null) ? input.ToString((IToken)(y.Start),(IToken)(y.Stop)) : null), ((z != null) ? input.ToString((IToken)(z.Start),(IToken)(z.Stop)) : null), ((n != null) ? input.ToString((IToken)(n.Start),(IToken)(n.Stop)) : null));
            			

            }

        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return ;
    }
    // $ANTLR end "point"


    // $ANTLR start "line"
    // G3D.g:48:1: line : LINE id= ID '=' p1= ID p2= ID (c= ID )? ;
    public void line() // throws RecognitionException [1]
    {   
        IToken id = null;
        IToken p1 = null;
        IToken p2 = null;
        IToken c = null;

        try 
    	{
            // G3D.g:49:2: ( LINE id= ID '=' p1= ID p2= ID (c= ID )? )
            // G3D.g:49:4: LINE id= ID '=' p1= ID p2= ID (c= ID )?
            {
            	Match(input,LINE,FOLLOW_LINE_in_line127); 
            	id=(IToken)Match(input,ID,FOLLOW_ID_in_line131); 
            	Match(input,51,FOLLOW_51_in_line133); 
            	p1=(IToken)Match(input,ID,FOLLOW_ID_in_line137); 
            	p2=(IToken)Match(input,ID,FOLLOW_ID_in_line141); 
            	// G3D.g:49:32: (c= ID )?
            	int alt3 = 2;
            	int LA3_0 = input.LA(1);

            	if ( (LA3_0 == ID) )
            	{
            	    alt3 = 1;
            	}
            	switch (alt3) 
            	{
            	    case 1 :
            	        // G3D.g:49:32: c= ID
            	        {
            	        	c=(IToken)Match(input,ID,FOLLOW_ID_in_line145); 

            	        }
            	        break;

            	}


            				m_modelBuilder.AddLine(((id != null) ? id.Text : null), ((p1 != null) ? p1.Text : null), ((p2 != null) ? p2.Text : null), ((c != null) ? c.Text : null));
            			

            }

        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return ;
    }
    // $ANTLR end "line"

    public class stringLiteral_return : ParserRuleReturnScope
    {
    };

    // $ANTLR start "stringLiteral"
    // G3D.g:55:1: stringLiteral : ( CharacterLiteral | StringLiteral );
    public G3DParser.stringLiteral_return stringLiteral() // throws RecognitionException [1]
    {   
        G3DParser.stringLiteral_return retval = new G3DParser.stringLiteral_return();
        retval.Start = input.LT(1);

        try 
    	{
            // G3D.g:56:2: ( CharacterLiteral | StringLiteral )
            // G3D.g:
            {
            	if ( (input.LA(1) >= CharacterLiteral && input.LA(1) <= StringLiteral) ) 
            	{
            	    input.Consume();
            	    state.errorRecovery = false;
            	}
            	else 
            	{
            	    MismatchedSetException mse = new MismatchedSetException(null,input);
            	    throw mse;
            	}


            }

            retval.Stop = input.LT(-1);

        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return retval;
    }
    // $ANTLR end "stringLiteral"

    public class integerLiteral_return : ParserRuleReturnScope
    {
    };

    // $ANTLR start "integerLiteral"
    // G3D.g:60:1: integerLiteral : ( '+' | '-' )? ( HexLiteral | OctalLiteral | DecimalLiteral | FloatingPointLiteral ) ;
    public G3DParser.integerLiteral_return integerLiteral() // throws RecognitionException [1]
    {   
        G3DParser.integerLiteral_return retval = new G3DParser.integerLiteral_return();
        retval.Start = input.LT(1);

        try 
    	{
            // G3D.g:61:5: ( ( '+' | '-' )? ( HexLiteral | OctalLiteral | DecimalLiteral | FloatingPointLiteral ) )
            // G3D.g:61:9: ( '+' | '-' )? ( HexLiteral | OctalLiteral | DecimalLiteral | FloatingPointLiteral )
            {
            	// G3D.g:61:9: ( '+' | '-' )?
            	int alt4 = 2;
            	int LA4_0 = input.LA(1);

            	if ( ((LA4_0 >= 52 && LA4_0 <= 53)) )
            	{
            	    alt4 = 1;
            	}
            	switch (alt4) 
            	{
            	    case 1 :
            	        // G3D.g:
            	        {
            	        	if ( (input.LA(1) >= 52 && input.LA(1) <= 53) ) 
            	        	{
            	        	    input.Consume();
            	        	    state.errorRecovery = false;
            	        	}
            	        	else 
            	        	{
            	        	    MismatchedSetException mse = new MismatchedSetException(null,input);
            	        	    throw mse;
            	        	}


            	        }
            	        break;

            	}

            	if ( (input.LA(1) >= HexLiteral && input.LA(1) <= FloatingPointLiteral) ) 
            	{
            	    input.Consume();
            	    state.errorRecovery = false;
            	}
            	else 
            	{
            	    MismatchedSetException mse = new MismatchedSetException(null,input);
            	    throw mse;
            	}


            }

            retval.Stop = input.LT(-1);

        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return retval;
    }
    // $ANTLR end "integerLiteral"

    // Delegated rules


	private void InitializeCyclicDFAs()
	{
	}

 

    public static readonly BitSet FOLLOW_point_in_model61 = new BitSet(new ulong[]{0x0000000000000052UL});
    public static readonly BitSet FOLLOW_line_in_model67 = new BitSet(new ulong[]{0x0000000000000052UL});
    public static readonly BitSet FOLLOW_POINT_in_point83 = new BitSet(new ulong[]{0x0000000000000020UL});
    public static readonly BitSet FOLLOW_ID_in_point87 = new BitSet(new ulong[]{0x0008000000000000UL});
    public static readonly BitSet FOLLOW_51_in_point89 = new BitSet(new ulong[]{0x0030000000001E00UL});
    public static readonly BitSet FOLLOW_integerLiteral_in_point96 = new BitSet(new ulong[]{0x0030000000001E00UL});
    public static readonly BitSet FOLLOW_integerLiteral_in_point100 = new BitSet(new ulong[]{0x0030000000001E00UL});
    public static readonly BitSet FOLLOW_integerLiteral_in_point104 = new BitSet(new ulong[]{0x0000000000000182UL});
    public static readonly BitSet FOLLOW_stringLiteral_in_point111 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_LINE_in_line127 = new BitSet(new ulong[]{0x0000000000000020UL});
    public static readonly BitSet FOLLOW_ID_in_line131 = new BitSet(new ulong[]{0x0008000000000000UL});
    public static readonly BitSet FOLLOW_51_in_line133 = new BitSet(new ulong[]{0x0000000000000020UL});
    public static readonly BitSet FOLLOW_ID_in_line137 = new BitSet(new ulong[]{0x0000000000000020UL});
    public static readonly BitSet FOLLOW_ID_in_line141 = new BitSet(new ulong[]{0x0000000000000022UL});
    public static readonly BitSet FOLLOW_ID_in_line145 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_set_in_stringLiteral0 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_set_in_integerLiteral187 = new BitSet(new ulong[]{0x0000000000001E00UL});
    public static readonly BitSet FOLLOW_set_in_integerLiteral198 = new BitSet(new ulong[]{0x0000000000000002UL});

}
}